package com.summer.demo.shiro.service.impl;

import com.summer.demo.shiro.service.IRedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.springframework.data.redis.core.StringRedisTemplate;

/**
 * @author yanglei0504
 * @date 18-7-8 下午5:39
 **/
@Service
public class RedisServiceImpl implements IRedisService {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void put(String key, String value) {
        if (StringUtils.isEmpty(key)) {
            return;
        }
        stringRedisTemplate.opsForValue().set(key, value);
    }

    @Override
    public String get(String key) {
        if (StringUtils.isEmpty(key)) {
            return null;
        }
        return stringRedisTemplate.opsForValue().get(key);
    }
}
